﻿//=======================================================
// Author: Jonas Follesø <jonas@follesoe.no>
// Copyright (c) 2008
//
// Licensed under the Microsoft Public License (Ms-PL)
// A copy of the license is available at 
// http://www.opensource.org/licenses/ms-pl.html
//=======================================================

using System;
using System.Linq;
using System.Windows;
using System.Collections.Generic;

namespace Colorful.Control.Services
{
    public class ClipboardManager
    {
        private ICopyColors[] formatters;

        internal IEnumerable<ICopyColors> Formatters
        {
            get
            {
                return formatters.AsEnumerable<ICopyColors>();
            }
        }

        public ClipboardManager(params ICopyColors[] formatters)
        {                       
            this.formatters = formatters;
        }

        public void AddToClipboard(Palette palette)
        {
            var data = new DataObject();
            foreach(ICopyColors formatter in Formatters)
            {
                formatter.AddToClipboard(data, palette);
            }
            Clipboard.SetDataObject(data, true);
        }

        public DataObject CreateDragDropObject(Palette palette)
        {
            var data = new DataObject();
            foreach (ICopyColors formatter in Formatters)
            {
                formatter.AddToClipboard(data, palette);
            }
            return data;
        }
    }
}